<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>

selection_test(
    [
        '<div id="d">',
            '<textarea id="textarea"></textarea>',
        '</div>',
        '<div id="d2" contenteditable="true"></div>',
    ],
    selection=> {
        const document = selection.document;
            document.addEventListener('keydown', function(e) {
                if (e.keyCode == 13)
                    document.getElementById('d').style.visibility = 'hidden';
            }, false);
        assert_not_equals(
            window.eventSender, undefined, 'This test requires eventSender');
        document.getElementById('textarea').focus();
        document.execCommand('InsertParagraph');
        eventSender.keyDown('Enter');
        document.getElementById('d2').focus();
        document.getElementById('d2').style.visibility = '';
        document.execCommand('InsertParagraph');
    },
    [
        '<div id="d" style="visibility: hidden;">',
            '<textarea id="textarea">\n</textarea>',
        '</div>',
        '<div contenteditable="true" id="d2">',
            '<div><br></div>',
            '<div>|<br></div>',
        '</div>'
    ],
    'insert line break in a hidden textarea does not crash.');
</script>
